package 树;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;

public class 二叉树的层序遍历 {
    public void layerOrder(TestTree root){
        if (root == null){
            return;
        }
        Queue queue = new LinkedList();
        queue.offer(root);

        while (!queue.isEmpty()){
            TreeNode node = (TreeNode) queue.poll();
            System.out.println(node.val);
            if (node.left != null){
                queue.offer(node.left);
            }
            if (node.right != null){
                queue.offer(node.right);
            }
        }
    }
}
